< previous page page_261 next page >

Page 261
Morphing full-color images has recently become popular in television and motion pictures. The basic idea is the same as for morphing line drawings. The differences lie in matching points in the key images and in handling color.
In the truck-to-plane animation, corresponding parts of the truck and plane are defined by the same number of points. The points are even arranged so that they line up somewhat. For example, points at the top of the truck correspond to points at the top of the plane. When you work with photographic images, making the points that define areas line up nicely is a little more difficult.
One method for mapping points between two images involves dividing the images into quadrilaterals. You can map the points in one quadrilateral to those in another using some rather messy mapping calculations. The process is similar to the way some of the programs described at the end of Chapter 7, Area Processes, map pixels from an output image back to an input image. The details of the calculation, however, are rather long, so they are not described here. You can see them in all their glory in the source code on the CD-ROM.
Program QuadMap, shown in Figure 9.9, uses these calculations to map points among three quadrilaterals. Click a point in one of the areas, and the program displays the corresponding points in the other two.
The values S and T tell how far through the quadrilaterals the points are positioned horizontally and vertically, though the quadrilaterals may be bent so far that these directions have little meaning. For example, in Figure 9.9, T is 0.90, so the points are 90 percent of the way from the left edge of the quadrilaterals to the right edge. S is 0.14, so the points are 14 percent of the way from the top of the quadrilaterals to the bottom.
Once you have code that maps points from one quadrilateral to another, you can specify these quadrilaterals on the images you want to morph. Superimpose a grid on both images. Adjust the points in the grids until corresponding points lie over corresponding points of the images. The grids define quadrilaterals that you can use to map points in one image to points in the other.
0261-01.jpg
Figure 9.9
Program QuadMap maps points in one
quadrilateral to points in two others.

 
< previous page page_261 next page >